package com.jinmdz.fmis.dao.admin.dao;

import com.jinmdz.fmis.dao.admin.model.hall.HallEditItem;
import com.jinmdz.fmis.dao.admin.model.hall.HallListItem;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;

/**
 * 守灵厅告别厅维护Dao
 *
 * @author LiCongLu
 * @date 2020-03-11 20:54
 */
public interface HallDao {

    /**
     * 查询礼厅列表
     *
     * @param
     * @return
     * @author LiCongLu
     * @date 2020-03-11 20:54
     */
    @Select(" select id,hall_type_code,hall_code,hall_name,hall_describe,hall_state,as_wake,as_farewell,disable_state,sort,remark,version " +
            "  from mourn_ceremony_hall where deleted = 0 order by sort")
    ArrayList<HallListItem> listHallList();

    /**
     * 按照主键获取礼厅信息
     *
     * @param id 主键
     * @return
     * @author LiCongLu
     * @date 2020-03-11 20:54
     */
    @Select(" select id,hall_type_code,hall_code,hall_name,hall_describe,hall_state,as_wake,as_farewell,disable_state,sort,remark,version " +
            "  from mourn_ceremony_hall where id = #{id} and deleted = 0 limit 1")
    HallEditItem getHallEditById(@Param("id") Integer id);

    /**
     * 按照礼厅编码查询非当前礼厅信息主键
     *
     * @param hallId   当前礼厅主键
     * @param hallCode 礼厅编码
     * @return
     * @author LiCongLu
     * @date 2020-03-11 20:54
     */
    @Select(" select id from mourn_ceremony_hall where id != IFNULL(#{hallId},0) and hall_code = #{hallCode} and deleted = 0 limit 1 ")
    @ResultType(Integer.class)
    Integer getHallIdByHallCode(@Param("hallId") Integer hallId, @Param("hallCode") String hallCode);


    /**
     * 按照礼厅编码查询礼厅信息主键
     *
     * @param hallId   礼厅主键
     * @param hallName 礼厅名称
     * @return
     * @author LiCongLu
     * @date 2020-03-13 11:37
     */
    @Select(" select id from mourn_ceremony_hall where id != IFNULL(#{hallId},0) and hall_name = #{hallName} and deleted = 0 limit 1 ")
    @ResultType(Integer.class)
    Integer getHallIdByHallName(@Param("hallId") Integer hallId, @Param("hallName") String hallName);
}
